package com.cddx.logistics.service.impl;

import com.cddx.logistics.domain.dto.SysPermissionQueryDTO;
import com.cddx.logistics.domain.pojo.SysPermission;
import com.cddx.logistics.domain.vo.SysPermissionVO;
import com.cddx.logistics.mapper.SysPermissionMapper;
import com.cddx.logistics.service.SysPermissionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;

@Service
public class SysPermissionServiceImpl implements SysPermissionService {
    @Resource
    private SysPermissionMapper sysPemissionMapper;
    @Override
    public PageInfo<SysPermissionVO> queryPage(SysPermissionQueryDTO sysPermission) {
        PageHelper.startPage(sysPermission.getPage(),sysPermission.getLimit());
        List<SysPermissionVO> sysdictVOList = sysPemissionMapper.queryPage(sysPermission);
        PageInfo<SysPermissionVO> pageInfo = new PageInfo<>(sysdictVOList);
        return pageInfo;
    }

    @Override
    public boolean delete(Integer id) {
        return sysPemissionMapper.delete(id)>0;
    }

    @Override
    public boolean add(SysPermission sysPermission) {
        sysPermission.setCreateTime(new Date());
        sysPermission.setUpdateTime(new Date());
        return sysPemissionMapper.add(sysPermission)>0;
    }

    @Override
    public boolean update(SysPermission sysPermission) {
        sysPermission.setUpdateTime(new Date());
        return sysPemissionMapper.update(sysPermission)>0;
    }
}
